﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="notification_panel.aspx.cs" Inherits="SQT.tracnghiem.Ajax.ASP.Notification.notification_panel" %>

<%@ Import Namespace="DataAccess" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<body>
    <ul class="notification-list">
        <% string adminID = Session["admin_id"].ToString();
            var NotificationColl = from p in new TblNotificationController().FetchAll().Where(x=>x.NotificationIsDelete==false && !String.IsNullOrEmpty(x.NotificationReceiver.ToString())) orderby p.NotificationDate descending select p;
            int NotificationCount = 0;
            foreach (TblNotification noti in NotificationColl)
            {%>
        <% string[] receivers = noti.NotificationReceiver.Split(',');
            foreach (string receiver in receivers)
            {
                if (receiver == adminID)
                {
                    var sender = new TblManagerController().FetchAll().Single(x => x.ManagerId == noti.NotificationSender);
        %>

        <li class="w3-row w3-hover-light-grey" onclick="ShowNotificationModal(<%= noti.NotificationId %>)">
            <div class="w3-col l2">
                <img src="../Content/avatar/<%= sender.Avatar %>" />
            </div>
            <div class="notification-content w3-col l9">
                <span class="notification-user"> <%= sender.FullName %> :</span>&nbsp;<span><%= noti.NotificationTitle %></span><br />
                <span class="notification-time w3-text-grey"><%= noti.NotificationDate %></span>
            </div>
            <div class="notification-action w3-col l1 w3-center">
                <%if (String.IsNullOrEmpty(noti.NotificationSeen.ToString()))
                        noti.NotificationSeen = "0";
                    if (noti.NotificationSeen.Contains(adminID))
                    {%>
                    <i class="fa fa-check" title="Đánh dấu đã đọc"></i>
                    <%}
                    else
                    { %>
                        <i class="mark-as-spam-btn fa fa-check" title="Đánh dấu đã đọc"></i><%
                        NotificationCount++;
                    }%>
            </div>
        </li>
               <%continue; }
            }
        }%>
    </ul>
    <div id="notification_count" hidden="hidden"><%= NotificationCount %></div>
</body>
</html>
